package com.fesine.quartz.chapter4;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.impl.StdSchedulerFactory;

import java.util.Properties;

/**
 * @description: 通过一个 java.util.Properties 实例来提供属性
 * @author: Fesine
 * @createTime:2016/11/16 16:49
 * @update:修改内容
 * @author: Fesine
 * @updateTime:2016/11/16 16:49
 */
public class Listing_4_2 {
    static Log logger = LogFactory.getLog(Listing_4_2.class);

    public static void main(String[] args) {
        Listing_4_2 example = new Listing_4_2();
        example.startScheduler();
    }

    public void startScheduler() {
        StdSchedulerFactory factory = new StdSchedulerFactory();
        //编程式设置配置文件
        Properties props = new Properties();
        //两个属性是必须的
        props.put(StdSchedulerFactory.PROP_THREAD_POOL_CLASS, "org.quartz.simpl.SimpleThreadPool");
        props.put("org.quartz.threadPool.threadCount", "10");
        try {
            factory.initialize(props);
            Scheduler scheduler = factory.getScheduler();
            logger.info("调度器启动。。。");
            scheduler.start();
        } catch (SchedulerException e) {
            e.printStackTrace();
        }
    }
}
